<template>
  <div class="form-visible-customer-setting">
    <el-checkbox :disabled="disabled" :value="field.isShow" @input="update" :true-label="1" :false-label="0">
      <i18n path="common.base.isAllowForModule" tag="span" :places="{module:$t('common.base.customer')}"></i18n>
      <el-tooltip :content="msgContent" placement="top">
        <i class="iconfont icon-question"></i>
      </el-tooltip>
    </el-checkbox>
  </div>
</template>

<script>
/* assist */
import { findComponentUpward } from '@src/util/assist';
/* props */
import { settingProps } from '@src/component/form/components/props';

export default {
  name: 'form-visible-customer-setting',
  props: {
    ...settingProps,
    // 当前表单控件的类型
    formControlType:{
      type:String,
      default:''
    },
    disabled: {
      type: Boolean,
      default: false
    },
  },
  computed: {
    // 是否是事件回执设置模式
    isEventReceipt() {
      return this.formMode === 'eventReceipt';
    },
    // 是否对客户可见提示文案
    msgContent() {
      let msg = this.$t('common.form.tip.formVisibleCustomerSetting.tips1')

      if(this.formMode === 'task') return this.$t('customer.customerVisibleTip');
      if(this.isEventReceipt || this.isBelongToSeparatorOrInfo) return msg;
      return this.$t('common.form.tip.formVisibleCustomerSetting.tips2', {msg});
    },
    // 表单mode
    formMode() {
      return findComponentUpward(this, 'form-design').mode;
    },
    // 当前表单控件是否属于分割线和说明信息
    isBelongToSeparatorOrInfo(){
      return this.formControlType === 'info' || this.formControlType === 'separator' || false
    }
  },
  methods: {
    update(value) {
      this.$emit('input', value, 'isShow');
    }
  }
}
</script>